


#ifndef PF_ACTIONINTERFACE_H
#define PF_ACTIONINTERFACE_H

#include <qobject.h>
#include <qaction.h>

#include "pf_entitycontainer.h"
#include "pf_commandevent.h"
#include "pf_event.h"
#include "pf_graphic.h"
#include "pf_graphicview.h"
#include "pf_mouseevent.h"
#include "pf_snapper.h"
#include "pf_preview.h"
#include "pf_dialogfactory.h"
#include "lx_String.h"
#include "lx_Export.h"

#include "pf_commands.h"

//template<class T> T* instantiate(PF_EntityContainer& container, PF_GraphicView& graphicView) {
//	return new T(container, graphicView);
	//void (*function)() = T::instantiate;
	//return (*function)();
//}

/**
 * This is the interface that must be implemented for all 
 * action classes. Action classes handle actions such
 * as drawing lines, moving entities or zooming in.
 *
 * Inherited from QObject for Qt translation features.
 *

 */
class LX_EXPORT PF_ActionInterface : public QObject, public PF_Snapper {
    Q_OBJECT
public:
    PF_ActionInterface(const char* name,
                       PF_Container& container,
                       PF_GraphicView& graphicView);
    virtual ~PF_ActionInterface();
	
    virtual LX_Define::ActionType rtti();

    PF_String getName();

    virtual void init(int status=0);
    virtual void mouseMoveEvent(QMouseEvent*);
    virtual void mousePressEvent(QMouseEvent*);

    virtual void mouseReleaseEvent(QMouseEvent*);
    virtual void keyPressEvent(QKeyEvent* e);
    virtual void keyReleaseEvent(QKeyEvent* e);
    virtual void coordinateEvent(PF_CoordinateEvent*);
    virtual void commandEvent(PF_CommandEvent*);
    virtual PF_StringList getAvailableCommands();
    virtual void setStatus(int status);
    virtual int getStatus();
    virtual void trigger();
    virtual void updateMouseButtonHints();
    virtual void updateMouseCursor();
    virtual void updateToolBar();
    virtual bool isFinished();
    virtual void setFinished();
    virtual void finish();
    virtual void setPredecessor(PF_ActionInterface* pre);
    virtual void suspend();
    virtual void resume();
    virtual void hideOptions();
    virtual void showOptions();
    bool checkCommand(const PF_String& cmd, const PF_String& str,
                             LX_Define::ActionType action=LX_Define::ActionNone);
	PF_String command(const PF_String& cmd);
	PF_String msgAvailableCommands();

private:
    /**
     * Current status of the action. After an action has
     * been created the action status is set to 0. Actions
     * that are terminated have a stats of -1. Other status
     * numbers can be used to describe the stage this action
     * is in. E.g. a window zoom consists of selecting the
     * first corner (status 0), and selecting the second
     * corner (status 1).
     */
    int status;

protected:
    /** Action name. Used internally for debugging */
    PF_String name;

    /**
     * This flag is set when the action has terminated and 
     * can be deleted.
     */
    bool finished;

    /**
     * Pointer to the graphic is this container is a graphic. 
     * NULL otherwise
     */
    PF_Graphic* graphic;

	/**
	 * Pointer to the document (graphic or block) or NULL.
	 */
	PF_Document* document;

    /**
     * Pointer to the default mouse cursor for this action or NULL.
     */
    //LX_Define::CursorType cursor;

    /**
     * Predecessor of this action or NULL.
     */
    PF_ActionInterface* predecessor;

    /**
     * String prepended to the help text for currently available commands.
     */
    //static PF_String msgAvailableCommands;

    /**
     * Command used for showing help for every action.
     */
    //static PF_String cmdHelp;
	
    /**
     * Command for answering yes to a question.
     */
    //static PF_String cmdYes;
    //static PF_String cmdYes2;
	
     /**
     * Command for answering no to a question.
     */
    //static PF_String cmdNo;
    //static PF_String cmdNo2;
};


#endif
